﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace KC.ExtensionMethods
{
	public static class Response
	{
		/// <summary>Returns a 301 Moved Permanently error and redirect url</summary>
		/// <param name="response">Http Response object</param>
		/// <param name="url">New URL / redirect to</param>
		public static void RedirectPermanent(this HttpResponseBase response, string url)
		{
			if (string.IsNullOrEmpty(url))
				throw new ArgumentNullException("url");
			if (response == null) 
				throw new ArgumentNullException("response");
			response.StatusCode = 301;
			response.Status = "301 Moved Permanently";
			response.RedirectLocation = url;
			response.End();
		}

	}
}
